import datetime


def red_print(content):
    print(f'\033[0;0;31m{content}\033[0m')


# 打印类内成员
def print_object(obj):
    print('\n'.join(['%s:%s' % item for item in obj.__dict__.items()]))


def print_object_map(obj_map):
    # 逐个打印字典中保存的类中的变量
    print(obj_map)
    for objName in obj_map.keys():
        print(objName)
        print_object(obj_map[objName])


# 一万条大概3.1秒，如果加上文件夹判断一万条大概3.6秒
def log(content):
    with open("./log/{}.log".format(datetime.datetime.now().strftime('%Y%m%d')), "a", encoding='utf-8') as f:
        f.write('{}: {}\n'.format(datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3], content))


# 一万条大概3.4秒
def timePrintLog(content):
    print('{}: {}'.format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3], content))
    log(content)


def red_printLog(content):
    print(f'\033[0;0;31m{content}\033[0m')
    log(content)


def timePrint(content):
    print('{}: {}'.format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3], content))
